home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / mathematica.544 < prev    next >
Text File  |  1992-02-06  |  4KB  |  117 lines

  1. {\rtf0\ansi{\fonttbl\f1\fnil Times-Roman;\f2\fmodern Courier;\f0\fswiss Helvetica;}
  2. \paperw14600
  3. \paperh9000
  4. \margl120
  5. \margr120
  6. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f1\b0\i0\ul0\fs28 mathematica fonts plots graphics text\
  7. \
  8. Q:  How do I change the font and style of the text that Mathematica generates for graphics (plots and graphs)?  This includes the x- and y-axis labels, titles, tick labels, etc.\
  9. \
  10. A:  You can take the following approaches to change fonts, font styles, and font sizes for Mathematica's graphics:\
  11. \
  12.  
  13. \b 1.  The FontForm[] object
  14. \b0 \
  15. You can use the
  16. \f2\fs24  FontForm[
  17. \i expr
  18. \i0 , "
  19. \i fontname
  20. \i0 ", 
  21. \i size
  22. \i0 ]
  23. \f1\fs28  object to set the font and size of any given string.  Normally, the 
  24. \f2\fs24 "
  25. \i fontname
  26. \i0 "
  27. \f1\fs28  argument only accepts 
  28. \f2\fs24 "Bold"
  29. \f1\fs28 , 
  30. \f2\fs24 "Italic"
  31. \f1\fs28 , or 
  32. \f2\fs24 "Plain"
  33. \f1\fs28  as arguments (in other words, a style, rather than a font).  If you want to change the font rather than the style, specify the actual PostScript code you would use to set a font for 
  34. \f2\i\fs24 fontname
  35. \f1\i0\fs28 .  This is done this way:\
  36. \
  37.     
  38. \f2\fs24 "/Times-Roman findfont"
  39. \f1\fs28 \
  40.     \
  41. or\
  42. \
  43.     
  44. \f2\fs24 "/Times-BoldItalic findfont"
  45. \f1\fs28 \
  46. \
  47.  
  48. \b\i Note:
  49. \b0\i0  Make sure you specify the correct spelling and case for the PostScript font name (this applies to the 
  50. \f2\fs24 findfont
  51. \f1\fs28  command as well).  Otherwise, unexpected results may occur.   \
  52. \
  53. Here's a way to find the correct font name:  create some sample text in a program like Draw (
  54. \f2\fs24 /NextDeveloper/Demos
  55. \f1\fs28 ) and set the font and style you want to use.  Copy the entire text object (not just the text) and paste it into Yap (
  56. \f2\fs24 /NextDeveloper/Demos
  57. \f1\fs28 ).  Yap displays the actual PostScript code that creates the text.  Near the end of the PostScript listing (there may be a lot of it), you'll be able to see the font name specified and how it should be referred to in the 
  58. \f2\fs24 "
  59. \i fontname
  60. \i0 "
  61. \f1\fs28  parameter.\
  62. \
  63. Here's an example that uses FontForm[] to change the font and/or style of several elements of a graphic:\
  64. \
  65.  
  66. \f2\fs24 Show [ \{Graphics[\
  67.      Text[FontForm["Hello","/Times-Roman findfont", 30], \{ 0.5, 0.5\}] ] \},\
  68.      Axes -> Automatic,\
  69.      AxesLabel -> \{FontForm["XLabel", "Italic", 18], FontForm["YLabel","Bold", 18]\},\
  70.      Ticks -> \{ \{\
  71.                     \{ 0.25, FontForm["B", "/Times-Italic findfont", 24]\},\
  72.                     \{ 0.50, FontForm["C", "/Times-Bold findfont", 24]\},\
  73.                     \{ 0.75, FontForm["D", "/Times-BoldItalic findfont", 24]\}\
  74.                     \},\
  75.                     Range[0, 1, .25] \}]
  76. \f1\fs28 \
  77. \
  78.  
  79. \b 2. The TeXForm[]
  80. \b0  
  81. \b object
  82. \b0 \
  83. Another way to change fonts and styles is to generate TeX output (assuming you are familiar with TeX).  This is useful if you want to display the graphic in another program.  To do this, use the 
  84. \f2\fs24 TeXForm[]
  85. \f1\fs28  object.  This produces straight TeX output in the Mathematica window.  You can then copy and paste this output (and modify it) where needed.\
  86. \
  87.  
  88. \b 3. The Display[]
  89. \b0  
  90. \b object
  91. \b0 \
  92. You can edit the PostScript code that defines the text in the graphic.  Generate a Mathematica PostScript file with the 
  93. \f2\fs24 Display["
  94. \i file
  95. \i0 ", 
  96. \i graphics
  97. \i0 ]
  98. \f1\fs28  object, where 
  99. \f2\fs24 "
  100. \i file
  101. \i0 "
  102. \f1\fs28  is the name of the file to be generated, and 
  103. \f2\i\fs24 graphics
  104. \f1\i0\fs28  is an expression that generates a graphic.  The resulting Mathematica PostScript file needs to be modified.  To do so, run the Shell program psfix (found in the Mathematica package) with the file you generated as an argument.  You can then modify the PostScript code to change the fonts and styles of the graphic's text.  The resulting file can be imported into any program that accepts .ps files.\
  105. \
  106.  
  107. \b 4. Viewing PostScript code in Mathematica
  108. \b0 \
  109. Alternatively, you can also directly edit the PostScript code that defines the text from within Mathematica.  You can view the PostScript code that Mathematica uses to display a graphic by selecting its cell.  Choose Formatted from the Cell menu (this is a toggle which unformats the text), edit the PostScript code that defines the text, and choose Formatted again to redisplay the graphic.\
  110. \
  111. QA544\
  112. \
  113. Valid for 1.0 \
  114. Valid for 2.0\
  115. \
  116.  
  117.